import { MockMethod } from "vite-plugin-mock";

const data: any[] = [
  {
    id: 1,
    ID: 1,
    typeId: 1,
    Name: '项目名称1',
    Desc: '项目简述\n1.xxxx\n2.xxxx',
    Description: '项目描述1',
    Cycle: 100,
    "Project Start Date": "2020-02-22",
    "Review Date": "2020-02-22 22:22:22",
    "Freeze": true,
    "Priority": "high",
    editables: [
      "Name",
      "Desc",
      "Description",
      "Cycle",
      "Project Start Date",
      "Review Date",
      "Freeze",
      "Priority",
    ],
    optionsMap: {
      Priority: [
        {label: "高", value: "high"},
        {label: "中", value: "midden"},
        {label: "低", value: "low", disabled: true},
      ]
    }
  },
  { id: 2, ID: 2, typeId: 1, Name: '项目名称2', Description: '项目描述2', editables:["Name", "Description", "Priority"] },
  { id: 3, ID: 3, typeId: 1, Name: '项目名称3', Description: '项目描述3', editables:["Name", "Description"] },
  { id: 4, ID: 4, typeId: 2, Name: '需求名称4', Description: '需求描述4', editables:["Name", "Description"] },
  { id: 5, ID: 5, typeId: 2, Name: '需求名称5', Description: '需求描述5', editables:["Name", "Description"] },
  { id: 6, ID: 6, typeId: 2, Name: '需求名称6', Description: '需求描述6', editables:["Name", "Description"] },
];

export default<MockMethod[]> [
  {
    url: '/api/record/getList',
    method: 'get',
    timeout: 600,
    response: ({ query }) => {
      let results = data;
      if (query?.typeId) {
        results = results.filter(item => item.typeId == query?.typeId);
      }
      return {
        result: true,
        code: 200,
        data: results
      }
    }
  },
  {
    url: '/api/record/view',
    method: 'get',
    timeout: 600,
    response: ({ query }) => {
      let result = {};
      if (query?.id) {
        result = data.find(item => item.id == query?.id);
      }
      return {
        result: true,
        code: 200,
        data: result
      }
    }
  },
]
